# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Rainy <rainylau(at)gmail(dot)com>
# Contributor: Lee.MaRS <leemars@gmail.com>
# Contributor: Hiroshi Yui <hiroshiyui@gmail.com>

pkgname=ibus-chewing
pkgver=1.6.1+12+gc1e7f0d
_commit=c1e7f0d97aa8bb1a1166621c3f0780daa0db06c1
pkgrel=4
pkgdesc='Chinese Chewing Engine for IBus Framework'
arch=('loong64' 'x86_64')
license=('GPL')
url='https://github.com/definite/ibus-chewing'
depends=('ibus' 'libchewing' 'libxtst' 'gtk3')
makedepends=('gob2' 'cmake-fedora' 'git')
source=("git+https://github.com/definite/ibus-chewing.git#commit=$_commit")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --always | sed 's/-/+/g'
}

prepare() {
  cd $pkgname

  # Revert an incomplete feature, see https://github.com/definite/ibus-chewing/issues/154
  git revert -n 70a1935290c9e8bcb8e098b91711f97269619c6f
}

build() {
  cd $pkgname

  cmake -B build -S . \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DLIBEXEC_DIR=/usr/lib/ibus

  # XXX: updated *.po files contain no translated strings. Maybe because fedora.zanata.org is down
  # https://github.com/definite/ibus-chewing/issues/150
  touch build/po/ibus-chewing.pot
  cp -v po/*.po build/po/

  make -C build -j1
}

package() {
  cd $pkgname/build
  make DESTDIR="$pkgdir" install
}
